package com.wl4837;

// 具体迭代器类
class BookShelfIterator implements Iterator<String> {

    private final BookShelf bookShelf;

    private int index = 0;

    public BookShelfIterator(BookShelf bookShelf) {
        this.bookShelf = bookShelf;
    }

    @Override
    public boolean hasNext() {
        return index < bookShelf.getLength();
    }

    @Override
    public String next() {
        return bookShelf.books[index++];
    }

}
